/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SettingsGui.java
 *
 * Created on 19-apr-2009, 23:19:04
 */
package tools.settings.gui;

import java.awt.Dimension;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import tools.settings.SettingsAdapter;

/**
 *
 * @author Lynne
 */
public class SettingsGui extends javax.swing.JFrame {

    SettingsAdapter sa = SettingsAdapter.getInstance();
    private boolean information_msg_on = true;

    /** Creates new form SettingsGui */
    public SettingsGui() {
        super("SettingsGUI");
        setPreferredSize(new Dimension(600, 600));
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabPane = new javax.swing.JTabbedPane();
        jmenubar = new javax.swing.JMenuBar();
        file_menu = new javax.swing.JMenu();
        file_open = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JSeparator();
        file_defdirectory = new javax.swing.JMenuItem();
        file_checkXML = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));
        getContentPane().add(tabPane);

        file_menu.setText("File");

        file_open.setText("Open File ...");
        file_open.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                file_openActionPerformed(evt);
            }
        });
        file_menu.add(file_open);
        file_menu.add(jSeparator2);

        file_defdirectory.setText("Set Default Directory");
        file_defdirectory.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                file_defdirectoryItemStateChanged(evt);
            }
        });
        file_defdirectory.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                file_defdirectoryActionPerformed(evt);
            }
        });
        file_menu.add(file_defdirectory);

        file_checkXML.setText("Check XML File ...");
        file_checkXML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                file_checkXMLActionPerformed(evt);
            }
        });
        file_menu.add(file_checkXML);

        jmenubar.add(file_menu);

        setJMenuBar(jmenubar);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void file_defdirectoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_file_defdirectoryActionPerformed
        // TODO add your handling code here:
        JSettingsPane.setDefaultFolderDialog(this);
}//GEN-LAST:event_file_defdirectoryActionPerformed

    private void file_defdirectoryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_file_defdirectoryItemStateChanged
        // TODO add your handling code here:
}//GEN-LAST:event_file_defdirectoryItemStateChanged

    private void file_openActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_file_openActionPerformed
        // TODO add your handling code here:
        JFileChooser chooser = new JFileChooser(sa.getDefault_folder());
        FileNameExtensionFilter filter = new FileNameExtensionFilter(
                "XML-files", "xml");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION)
            openFile(chooser.getSelectedFile());
    }//GEN-LAST:event_file_openActionPerformed

    private void file_checkXMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_file_checkXMLActionPerformed
        // TODO add your handling code here:
        JSettingsPane.checkXMLFile(this);
}//GEN-LAST:event_file_checkXMLActionPerformed

    private void openFile(File bestand) {
        // TODO bestand openen.
        JOptionPane.showMessageDialog(this, "Not yet implemented.","Oops ...",  JOptionPane.INFORMATION_MESSAGE);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new SettingsGui().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem file_checkXML;
    private javax.swing.JMenuItem file_defdirectory;
    private javax.swing.JMenu file_menu;
    private javax.swing.JMenuItem file_open;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JMenuBar jmenubar;
    private javax.swing.JTabbedPane tabPane;
    // End of variables declaration//GEN-END:variables
}
